import new;

class BaseProtocal:

    def __init__(self,msgType = 0):
        self.msgType = msgType
        pass

    def read(self,data):
        pass
    
class BaseHandler:

    def __init__(self):
        pass
        
    def process(self,protocal):
        pass   
 
class DummyHandler(BaseHandler):

    def process(self,protocal):
        pass
    
class ProtocalPool:
    
    def __init__(self):
        self.defaultHandler = DummyHandler()
        self.handlers = {}
        self.protocals = {}
    
    def register(self,protocalType,protocalClazz,handler):
        self.handlers[protocalType] = handler
        self.protocals[protocalType] = protocalClazz
    
    def getHandler(self,protocalType):
        handler = self.handlers[protocalType]
        if(not handler):
            handler = self.defaultHandler
        return handler
    
    def getProtocal(self,protocalType):
        protocalClazz = self.protocals[protocalType]
        if(not protocalClazz) :
            return None;
        return new.instance(protocalClazz);